﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Com.Mapabc.Maps.Api.Overlays;
using Com.Mapabc.Maps.Api.BaseTypes;
using Com.Mapabc.Maps.Api;

namespace MapABCAPI_WP7.Samples
{
    /// <summary>
    /// 信息窗体
    /// </summary>
    public partial class Tip : PhoneApplicationPage
    {
        public Tip()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 添加信息窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddTip(object sender, GestureEventArgs e)
        {
            button3.Visibility = System.Windows.Visibility.Visible;//显示按钮控件
            button4.Visibility = System.Windows.Visibility.Visible;//显示按钮控件   
            Pivot.SelectedIndex = 1;//显示效果
        }      
        private void openMapTip(object sender, RoutedEventArgs e)
        {        
            MTip tip = new MTip();
            tip.ContentText = "信息窗体的内容";//tip内容 
            tip.ContentFontColor = Colors.Black;//内容的字体颜色 
            tip.ContentFontFamily = new FontFamily("NSimsun");//内容字体的FontFamily 
            tip.ContentFontSize = 12;// 内容字体大小
            tip.ContentFontWeight = FontWeights.Normal;//内容的字体笔画的粗细 
            tip.ContentFillColor = Colors.White;//内容的填充颜色
            tip.ContentFillOpacity = 0.8;//内容的透明度
            tip.Title = "信息窗体的标题";//tip标题
            tip.TitleFontColor = Colors.Black;//标题的字体颜色 
            tip.TitleFontFamily = new FontFamily("NSimsun");//标题字体的FontFamily 
            tip.TitleFontSize = 15;//标题字体大小
            tip.TitleFontWeight = FontWeights.Bold;//标题的字体笔画的粗细 
            tip.TitleFillColor = Colors.White;//标题填充颜色 
            tip.TitleFillOpacity = 1;//标题的透明度
            tip.StrokeThickness = 3;//边框宽度 
            tip.Size = new Size(200, 80);//tip宽高
            map.OpenTip(new MLngLat(116.204518485069, 39.8485546373702), tip);//打开信息窗体
        }

        private void closeMapTip(object sender, RoutedEventArgs e)
        {
            map.CloseTip();//关闭信息窗体
        }
        /// <summary>
        /// 重写后退键
        /// </summary>
        /// <param name="e"></param>
        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            if (Pivot.SelectedIndex == 1)
            {
                e.Cancel = true;
                Pivot.SelectedIndex = 0;
            }
        }
    }
}